var play_background = true;

var startgame = function () {

    //called when page loads to initialize game
    window.game.system = new System(30, 'game_canvas');

    //resize canvas
    var scaling = new Scaling();
    scaling.resize(null);
    //scaling.resize();
    window.addEventListener("resize", scaling.resize);
}

window.onload = () => {

    //Setup Request Animation Frame usage
    var prefixes = ['ms', 'moz', 'webkit'];
    for (var i = 0; i < prefixes.length && !window.requestAnimationFrame; i++) {
        window.requestAnimationFrame = window[prefixes[i] + 'RequestAnimationFrame'];
        window.cancelAnimationFrame = window[prefixes[i] + 'CancelAnimationFrame'];
    }

    window.game = {
        system: null, isPaused: false, Entity: new Entity(), Frame: Frame, ui: UI, UI: UI, Mountain: null, SoundManager: null, Yeti: null,
        Snowball: null, map: null, Input: null, HikerManager: null, hiker: null, frame: null, Hiker: null
    }

    window.game.SoundManager = SoundManager;
    window.game.Yeti = Yeti;
    var entity = new Entity();
    var ui = new UI();
    window.game.Snowball = Snowball;
    window.game.Mountain = Mountain;
    window.game.Hiker = Hiker;
    window.game.map = map;
    //var map = new map();
    window.game.Input = Input;
    window.game.HikerManager = HikerManager;
    //var hiker = Hiker;
    //Init Game Namespace
    //window.game = { system: null, isPaused: false, Entity: entity, mountain: mountain, soundManager: soundManager, yeti: yeti, UI: ui, snowball: snowball, map: map, input: input, hikerManager: hikermanager, hiker: Hiker, frame: Frame }

    startgame();  //starts the game
    window.game.isPaused = false;


};